local thbattle__cheng_shishen = fk.CreateSkill {

  name = "thbattle__cheng_shishen",

  tags = { Skill.Limited, },

}



thbattle__cheng_shishen:addEffect("active", {
  anim_type = "big",
  target_num = 1,
  target_filter = function(self, player, to_select, selected, selected_cards, card, extra_data)
    return not to_select:hasSkill(thbattle__cheng_shishen.name) and #selected == 0
  end,
  can_use = function(self, player, card, extra_data)
    return player:hasSkill(thbattle__cheng_shishen.name) and
    player:usedSkillTimes(thbattle__cheng_shishen.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, room, cardUseEvent)
    local player = cardUseEvent.from
    local target = cardUseEvent.tos[1]
    local choices={"摸两张牌"}
    if target:isWounded() then
      table.insert(choices,"回复一点体力")
    end
    local choice = room:askForChoice(target, choices, thbattle__cheng_shishen.name)
    if choice == "摸两张牌" then
      target:drawCards(2, thbattle__cheng_shishen.name)
    else
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = thbattle__cheng_shishen.name
      })
    end
    room:addPlayerMark(player, "@@thbattle__cheng_shishen")
    room:addPlayerMark(target, "@@thbattle__cheng_shishen")
  end
})

thbattle__cheng_shishen:addEffect("targetmod", {
  bypass_distances = function(self, player, skill, card, to)
    local room=Fk:currentRoom()
    local players=table.filter(room.alive_players,function (p)
      return p:getMark("@@thbattle__cheng_shishen")>0
    end)
    if #players>1 then
      for _, p in ipairs(players) do
        if p:inMyAttackRange(to) and card.trueName=="slash" and player.phase==Player.Play then
          return true
        end
      end
    end
  end
})

thbattle__cheng_shishen:addEffect(fk.TurnStart, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__cheng_shishen.name) and
    player:getMark("@@thbattle__cheng_shishen") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    for _, p1 in ipairs(player.room.alive_players) do
      if p1:getMark("@@thbattle__cheng_shishen") > 0 then
        player.room:removePlayerMark(p1, "@@thbattle__cheng_shishen")
      end
    end
  end
})

return thbattle__cheng_shishen
